<template>
  <el-select v-model="selections" clearable @change="feiSelect" placeholder="请选择分类">
    <el-option
      v-for="item in deptOptions"
      :key="item.id"
      :label="item.name"
      :value="item.id"
    >
    </el-option>
  </el-select>
</template>

<script>
import Treeselect from "@riophae/vue-treeselect";
import { listErpMaterialModel } from "@/api/wms/materiaModel";
export default {
  components: { Treeselect },
  props: {
    value: {
      type: [String, Number, Array],
      default: null,
    },
    size: {
      type: String,
      default: "small",
    },
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      deptOptions: [],
    };
  },
  computed: {
    selections: {
      get() {
        return this.value;
      },
      set(v) {
        this.$emit("input", v);
      },
    },
  },
  created() {
    listErpMaterialModel().then((response) => {
      this.deptOptions = response;
    });
  },
  methods: {
    feiSelect(node) {
      // 触发自定义事件，并传递选中项的id和name
      let dept = this.deptOptions.filter((e)=>e.id == node)[0]
      this.$emit("elselect", dept);
    },
  },
};
</script>
